﻿using D.UtilCore;
using D.UtilCore.Dtos;
using D.UtilCore.Filters;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using CozeDto.RechargeHistoryDtos;
using CozeDomain.IServices;
using D.UtilFreesqlOrm;

namespace CozeWapApi
{
    /// <summary>
    /// 用户充值模块
    /// </summary>
    [Route("/api/[controller]/[action]")]
    public class RechargeHistoryController : BaseApiController
    {
        private readonly IRechargeHistoryService _rechargeHistoryService;
        public RechargeHistoryController(IRechargeHistoryService rechargeHistoryService)
        {
            _rechargeHistoryService = rechargeHistoryService;
        }

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="reqAddRechargeHistory"></param>
        /// <returns></returns>
        [HttpPost, TypeFilter(typeof(ExtActionFilterAttribute))]
        [Authorize]
        public async Task<ApiResult<int>> Add([FromBody] ReqAddRechargeHistory reqAddRechargeHistory)
        {
            reqAddRechargeHistory.CreateUser = Account;
            return await _rechargeHistoryService.AddRechargeHistoryAsync(reqAddRechargeHistory);
        }

        /// <summary>
        /// 分页
        /// </summary>
        /// <returns></returns>
        [HttpPost, TypeFilter(typeof(ExtActionFilterAttribute))]
        [Authorize]
        public async Task<ApiResult<PageModel<RepRechargeHistoryInfo>>> Pages([FromBody] ReqQueryRechargeHistoryPage reqQueryRechargeHistoryPage)
        {
            return await _rechargeHistoryService.QueryRechargeHistoryPagesAsync(reqQueryRechargeHistoryPage);
        }
    }
}
